<!--
 * @Author: your name
 * @Date: 2021-08-03 13:36:05
 * @LastEditTime: 2021-08-12 13:26:42
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \getHome (2)\src\components\discounts\amend.vue
-->
<!--短信发放记录-->
<template>
  <div>
    <div class="herdertop">
      <img src="../../assets/top.png" alt="" class="topImg" />
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>通知管理</el-breadcrumb-item>
        <el-breadcrumb-item>短信发放记录</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="center" style="padding-top: 0px;">
      <div class="hander">短信发放记录</div>
      <div class="entirety">
        <div class="search">
          <!--  账号状态搜索信息 -->

          <div class="demo-input-suffix">
            发送节点

            <el-select v-model="dictCode" placeholder="请选择">
              <el-option
                v-for="item in business"
                :key="item.dictCode"
                :label="item.dictName"
                :value="item.dictCode"
              >
              </el-option>
            </el-select>
          </div>
          <div class="news">
            <div class="userSearch">
              <el-select
                v-model="userSearch"
                placeholder="请选择"
                @change="changeSelect"
              >
                <el-option
                  v-for="item in staffSearch"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
              <el-input v-model="searchValue" placeholder="请输入"></el-input>
              <!-- <el-button
                icon="el-icon-search"
                @click="searchForUserInformation"
              ></el-button> -->
            </div>
          </div>
          <!--  账号状态搜索信息 -->
          <div class="demo-input-suffix" style="margin-right:35px">
            <el-button
              style="background-color:#fd804c;color: #fff;"
              @click.native.prevent="isSelect"
              >查询</el-button
            >
            <el-button type="warning" @click.native.prevent="isEmpty"
              >清空</el-button
            >
          </div>
        </div>
      </div>
      <!--  员工列表栏位-->

      <div class="entirety">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="id" label="序号" width="140">
            <template slot-scope="scope">
              <div>
                {{ scope.row.id }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="sendNode" label="发送节点" width="140">
            <template slot-scope="scope">
              <div>
                {{ scope.row.sendNode }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="content" label="通知内容" width="230">
            <template slot-scope="scope">
              <div>
                {{ scope.row.content }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="nickName" label="服务联系人" width="140">
            <template slot-scope="scope">
              <div>
                {{ scope.row.nickName }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="phoneNum" label="联系人手机号" width="140">
            <template slot-scope="scope">
              <div>
                {{ scope.row.phoneNum }}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="sendStatus" label="发送状态" width="140">
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.sendStatus == 1
                    ? "等待回执"
                    : scope.row.sendStatus == 2
                    ? "发送失败"
                    : "发送成功"
                }}
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div class="block">
          <div class="left"></div>
          <div class="right">
            <el-pagination
              layout="total, sizes, prev, pager, next, jumper"
              class="page"
              @size-change="sizeChangeHandle"
              @current-change="currentChangeHandle"
              :current-page="pageIndex"
              :page-size="pageSize"
              :total="total"
            >
            </el-pagination>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pageIndex: 1,
      pageSize: 20,
      total: 0,
      tableData: [],

      nickName: "",
      phoneNum: "",
      searchValue: "",
      userSearch: 0,

      staffSearch: [
        { value: 0, label: "联系人姓名" },
        { value: 1, label: "联系人手机号" }
      ],
      dictCode: "",
      parentCode: "",
      business: [],
      multipleSelection: []
    };
  },
  activated() {
    this.DetailByPage();
    this.AllSendNode();
  },

  methods: {
    isSelect() {
      //console.log("userSearch,,,,dsdsd,", this.userSearch);
      if (this.userSearch === 0) {
        this.nickName = this.searchValue || "";
      } else {
        this.phoneNum = this.searchValue || "";
      }

      (this.pageIndex = 1), (this.pageSize = 20), this.DetailByPage();
    },

    isEmpty() {
      (this.pageIndex = 1),
        (this.pageSize = 20),
        (this.nickName = ""),
        (this.phoneNum = ""),
        (this.searchValue = ""),
        (this.userSearch = 0),
        (this.dictCode = ""),
        (this.parentCode = ""),
        this.DetailByPage();
    },
    // 切换搜索条件清空数据
    changeSelect() {
      (this.searchValue = ""), (this.nickName = ""), (this.phoneNum = "");
    },
    //分页获取优惠券模板列表接口调用
    DetailByPage() {
      this.$http({
        url: `/messageadmin/smsRecord/selectSmsSenLogList`,
        method: "GET",
        params: {
          dictCode: this.dictCode,
          parentCode: this.parentCode,
          nickName: this.nickName,
          phoneNum: this.phoneNum,
          currentPage: this.pageIndex,
          pageSize: this.pageSize
        }
      }).then(res => {
        this.tableData = res.data.list;

        this.total = parseInt(res.data.total);
      });
    },
    //查询全部发送节点
    AllSendNode() {
      this.$http({
        url: `/messageadmin/smsRecord/selectSmsSendNode`,
        method: "GET"
      }).then(res => {
        this.business = res.data;
      });
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.DetailByPage();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.DetailByPage();
    }
  }
};
</script>
<style scoped lang="scss">
.block {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  padding: 0 10px 0 10px;
}
.left {
  font-size: 15px;
}
.hander {
  width: 100%;
  height: 50px;
  line-height: 50px;
  font-size: 20px;
  font-weight: 900;
}
.herdertop {
  height: 8vh;
  display: flex;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
}
.topImg {
  margin-right: 20px;
}
.news {
  margin-left: 1%;
}
.entirety {
  width: 95%;
  margin: 10px;
  border: 7px solid #fafafa;
  border-radius: 10px;
  .basic {
    font-size: 18px;
    font-weight: 900;
    margin-top: 2%;
    margin-bottom: 1%;

    margin-left: 1%;
  }
}

.overall {
  width: 100%;
  height: auto;
  display: flex;

  justify-content: space-between;
  margin-top: 3%;
  .left {
    width: 20%;
    height: auto;
  }
  .right {
    width: 80%;
    height: auto;
  }
}
.demo-input-suffix {
  margin-left: 2%;
}
.select {
  width: 65%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}
.userSearch {
  display: flex;
  /deep/ .el-input__inner {
    box-sizing: border-box;
    height: 40px;
    border-radius: 0;
    width: 132px;
    border: 1px solid #dcdfe6;
  }
  /deep/ .el-icon-arrow-up:before {
    position: relative;
    top: -4px;
  }
  /deep/ .el-button {
    height: 40px;
    border-radius: 0;
    background-color: #fff;
    border: 1px solid #dcdfe6;
    border-left: none;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
    position: relative;
    .el-icon-search {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-right: none;
  }
  /deep/ .el-input--suffix .el-input__inner {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}
.selects {
  width: 55%;
  height: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .dialog-footer,
  .choice {
    margin-left: 2%;
  }
}

/deep/ .but {
  background: #fd7097;
  color: #fff;
  margin-bottom: 1%;
}
</style>
